package com.yvon.service.demo.mybatis.executor;

import com.yvon.service.demo.mybatis.mapping.BoundSql;
import com.yvon.service.demo.mybatis.mapping.MappedStatement;
import com.yvon.service.demo.mybatis.session.ResultHandler;
import com.yvon.service.demo.mybatis.transaction.Transaction;

import java.sql.SQLException;
import java.util.List;

/**
 * 在执行器中定义的接口包括事务相关的处理方法和执行SQL查询的操作
 *
 * @author Yvon
 * @since 2023/4/14
 */
public interface Executor {

    ResultHandler NO_RESULT_HANDLER = null;

    <E> List<E> query(MappedStatement ms, Object parameter, ResultHandler resultHandler, BoundSql boundSql);

    Transaction getTransaction();

    void commit(boolean required) throws SQLException;

    void rollback(boolean required) throws SQLException;

    void close(boolean forceRollback);

}
